import Vue from 'vue'
import Vuex from 'vuex'
import menu from "../utils/menu";

Vue.use(Vuex)
export default new Vuex.Store({
    state: {
        width: 0,
        height: 0,
        refresh: true,
        menuList: menu,
        Breadcrumb: ['1', '2', '3', '4'] // 1增2删3改4查
    },
    mutations: {
        editwidth(state, data) {
            state.width = data
        },
        editheight(state, data) {
            state.height = data
        },
        setBreadcrumb(state, data) {
            state.Breadcrumb = data
        },
        setMenuList(state, data) {
            state.menuList = data
        },
        setRefresh(state, data) {
            state.refresh = data
        },
        setMenu(state, data) {
            if (data) {
                state.menuList = [{
                    name: '首页',
                    icon: 'md-home',
                    path: '/'
                },
                    {
                        name: '用户管理',
                        icon: 'md-home',
                        path: '/user/index'
                    },
                    {
                        name: '权限管理',
                        icon: 'md-share-alt',
                        path: '/jurisdiction',
                        children: [{
                            name: '权限列表',
                            path: '/jurisdiction/index'
                        },
                            {
                                name: '角色列表',
                                path: '/jurisdiction/role'
                            }

                        ]
                    }]
            } else {
                state.menuList = [{
                    name: '首页',
                    icon: 'md-home',
                    path: '/'
                },
                    {
                        name: '用户管理',
                        icon: 'md-home',
                        path: '/user/index'
                    }]
            }
        }
    },
    actions: {},
    modules: {}
    // plugins: [persistedState()]
})
